package de.wolvan.main;


import java.net.URI;
import java.net.URISyntaxException;

import de.wolvan.autoupdate.*;
import de.wolvan.dataClient.*;
import de.wolvan.references.*;
import de.wolvan.window.*;
import org.java_websocket.drafts.Draft_10;

public class main {
	public static WS c;
	
	public static void main(String[] args) {
		writeInfo();
		if(UpdateChecker.isUpdateAvailable()) {
			UpdateGUI.renderGUI();
		} else {
			if(args.length != 0) {
				if(args[0].startsWith("removeOldVersion;")) {
					
					UpdateFile.delFile(args[0].split(";")[1]);
				}
			}
			LoginWindow.renderGUI();
		}
	}
	
	public static void writeInfo() {
		System.out.println("[Info]" + metadata.name + " v" + metadata.version + " by " + metadata.developer + " initializing");
		System.out.println("[Info]XIM Build: " + xim.build);
		System.out.println("[Info]Connecting to XIM Server " + xim.serverFullPath);
	}

	public static void openWS() throws URISyntaxException{
		c = new WS( new URI( xim.serverFullPath ), new Draft_10() ); // more about drafts here: http://github.com/TooTallNate/Java-WebSocket/wiki/Drafts
		c.connect();
	}
	
	
}